package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceSaveParam;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/geofence/")
public class GeofenceController {
    @Autowired
    GeofenceService geofenceService;

    @GetMapping("select")
    public JsonResult select(GeofenceQuery geofenceQuery){
        log.debug("开始处理查询电子围栏的请求，参数：{}",geofenceQuery);
        List<GeofenceVO> list = geofenceService.select(geofenceQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult insert(GeofenceSaveParam geofenceSaveParam){
        log.debug("开始处理保存电子围栏的请求，参数：{}",geofenceSaveParam);
        geofenceService.insert(geofenceSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        log.debug("开始处理删除电子围栏的请求，参数：{}",id);
        geofenceService.delete(id);
        return JsonResult.ok();
    }

}
